<?php
/**
 * Created by PhpStorm.
 * User: mojie126
 * Date: 2017/6/7
 * Time: 下午8:55
 */

namespace app\common;


class imdb
{
	static public function getIMDbRating($imdburl)
	{
		$imdb = "";
		if (preg_match("/[0-9]+/", $imdburl, $matches)) {
			$imdb = sprintf("%07d", $matches[0]);
		}
		$apikey = "d5c78be0-5e0a-46da-bf25-1691ba55eece";
		$url = "http://api.myapifilms.com/imdb/idIMDB?idIMDB=tt$imdb&token=$apikey";
		$imdb = json_decode(mycurl($url));
		if (!empty($imdb->error)) {
			return "";
		} else {
			if (@$imdb->data->movies[0]->rating) {
				return $imdb->data->movies[0]->rating;
			} else {
				return "";
			}
		}
	}
}